package com.lpl.restful.controller;

import com.lpl.restful.entity.User;
import com.lpl.restful.service.UserService;
import com.lpl.restful.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lipenglong
 * @version 1.0
 * @describe
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/selectUserById/{userId}")
    public ResponseResult<User> selectByPrimaryKey(@PathVariable("userId") Integer userId){
        User user = userService.selectByPrimaryKey(userId);
        if (user != null){
            return ResponseResult.success(user);
        }else {
            return ResponseResult.notFound();
        }
    }
}
